package com.joker.yuwu;

import net.sf.json.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/rootlogin")
public class RootLogin extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doGet(req, resp);
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/json; charset=utf-8");
        String root=req.getParameter("root");
        String pass= req.getParameter("pass");
        System.out.println("输出root用户账号密码"+root+pass);
        JSONObject obj=new JSONObject();
        if(root.equals("root") && pass.equals("123456")){
//            obj.put("data","true");
//            resp.getWriter().write(obj.toString());

            resp.sendRedirect("/admin/index.html");

        }
        else {
            obj.put("data","账号密码错误");
            resp.getWriter().write(obj.toString());
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doPost(req, resp);
    }
}
